home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: 500 MB Amiga Software / 500 MB Amiga Software - Euber 130 - Amiga Games Disc & Mag.iso / userbox / publicdomain / tinymeter / source / tinymeter_main / main.c < prev    next >
C/C++ Source or Header  |  1995-11-16  |  3KB  |  204 lines

  1. #include "includes.h"
  2. #include "structs.h"
  3. #include <libraries/commodities.h>
  4.  
  5. int __nocommandline=1;
  6.  
  7. struct tm_settings dftm =
  8. {
  9.     1L,
  10.     20L,
  11.     256L,
  12.     0L,
  13.     3,
  14.     7,
  15.     1,
  16.     1,
  17.     0,
  18.     1,
  19.     "topaz.font",
  20.     8,
  21.     TRUE,
  22.     FALSE,
  23.     "",
  24.     "",
  25.     0,
  26.     0,
  27.     0,
  28.     0,
  29.     0,
  30.     1,
  31.     0,
  32.     0,
  33.  
  34.     1,
  35.  
  36.     "Chip",
  37.     "Fast",
  38.     "Retina",
  39.     "Virtual",
  40.  
  41.     0,
  42.  
  43.     FALSE,
  44.     0,
  45.  
  46.     0,
  47.  
  48.     8,
  49.     5,
  50.     8,
  51.  
  52.     FALSE,
  53.  
  54.     "%td Bytes free",
  55.  
  56.     FALSE,
  57.     TRUE,
  58.     TRUE,
  59.  
  60.     "Memory",
  61.  
  62.     "%tlc | %tlf",
  63.     "%tc | %tf",
  64.  
  65.     FALSE,
  66.     FALSE,
  67.  
  68.     TRUE,
  69.  
  70.     0,
  71.  
  72.     "%tkd KB, %p%% free",
  73.  
  74.     10,
  75.  
  76.     TRUE,
  77.     TRUE,
  78.  
  79.     0,
  80.     0,
  81.  
  82.     "TinyMeter_DIGITAL.font",
  83.     17,
  84.     "TinyMeter_DIGITAL.font",
  85.     11,
  86.  
  87.     0,
  88.  
  89.     1,
  90.     0,
  91.     0,
  92.  
  93.     FALSE,
  94.  
  95.     TRUE,
  96.  
  97.     2,
  98.  
  99.     "Idle",
  100.     "%p %% free",
  101.     0,
  102.  
  103.     FALSE,
  104.     FALSE
  105. };
  106.  
  107. struct Library          *ShutdownBase;
  108. struct Library          *RetinaBase;
  109. struct Library          *TimerBase;
  110.  
  111. ULONG                    bas_c_ram,
  112.                          bas_f_ram,
  113.                          act_c_ram,
  114.                          act_f_ram,
  115.                          all_c_ram,
  116.                          all_f_ram,
  117.  
  118.                          all_r_ram,
  119.                          bas_r_ram,
  120.                          act_r_ram,
  121.  
  122.                          all_o_ram[32],
  123.                          bas_o_ram[32],
  124.                          act_o_ram[32],
  125.  
  126.                          bas_idle;
  127.  
  128.  
  129. extern struct WBStartup *_WBBenchMsg;
  130. extern struct Library   *CxBase;
  131. extern struct Library   *DataTypesBase;
  132.  
  133. extern ULONG  idle,maximum;
  134.  
  135. extern BOOL   InitIdle;
  136.  
  137. struct NewBroker newbroker =
  138. {
  139.     NB_VERSION,  
  140.     "TinyMeter V3.62",
  141.     "TinyMeter V3.62 © by Tinic Urou",
  142.     "Shows memory-&volumesusage, date&time",
  143.     NBU_UNIQUE,
  144.     0,           
  145.     -3,
  146.     0,          
  147.     0        
  148. };
  149.  
  150. int main(void)
  151. {
  152.     ULONG            cxsigflag;
  153.     UBYTE           *my_file;
  154.     CxMsg           *msg;
  155.     CxObj           *broker;
  156.     struct MsgPort  *broker_mp;
  157.     char  *version="$VER: TinyMeter V3.62";
  158.  
  159.     SetTaskPri(FindTask(0L),-3);
  160.     if(broker_mp = (struct MsgPort *)CreatePort(0,0))
  161.     {
  162.         newbroker.nb_Port = (struct MsgPort *)broker_mp;
  163.  
  164.         if (broker = (CxObj *)CxBroker(&newbroker, NULL))
  165.         {
  166.             cxsigflag = 1L << broker_mp->mp_SigBit;
  167.             ActivateCxObj(broker, 1L);
  168.  
  169.             if(my_file=(UBYTE *)Open("ENV:TinyMeter",MODE_OLDFILE) )
  170.             {
  171.                 Read(my_file,&dftm,(ULONG)sizeof(struct tm_settings));
  172.                 Close(my_file);
  173.                 if(dftm.VolRefreshTime==0)  dftm.VolRefreshTime=10;
  174.                 if(dftm.colums<1)           dftm.colums=1;
  175.             }
  176.  
  177.             if(RetinaBase=(struct Library *)OpenLibrary("retina.library",0L)) all_r_ram=Retina_AvailMem(MEMF_TOTAL)+256L; else all_r_ram=256L;
  178.  
  179.             all_c_ram=AvailMem( MEMF_TOTAL | MEMF_CHIP )+256L;
  180.             all_f_ram=AvailMem( MEMF_TOTAL | MEMF_FAST )+256L;
  181.  
  182.             Delay(dftm.WaitSeconds*50);
  183.  
  184.             makeall();
  185.  
  186.             intui_handler(broker_mp,broker,cxsigflag);
  187.  
  188.             free_all();
  189.  
  190.             if(InitIdle)
  191.             {
  192.                 free_idle();
  193.                 InitIdle=FALSE;
  194.             }
  195.  
  196.             if(RetinaBase)CloseLibrary( RetinaBase );
  197.  
  198.             DeleteCxObj(broker);
  199.             while(msg = (CxMsg *)GetMsg(broker_mp)) ReplyMsg((struct Message *)msg);
  200.         }
  201.         DeletePort(broker_mp);
  202.     }
  203. }
  204.